package com.hdc.service;

import com.hdc.HealthDeviceRemote;
import com.hdc.dao.DongMaiPoDao;
import com.hdc.po.BasePo;
import com.hdc.po.DongMaiPo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by chenyq5 on 2016-11-14.
 */
@Service("dongMaiImpl")
public class DongMaiImpl implements HealthDeviceRemote {
    @Autowired
    private DongMaiPoDao dongMaiPoDao;
    protected final static Logger log = LoggerFactory.getLogger(DongMaiImpl.class);

    public boolean saveOrUpdate(BasePo po) {
        boolean result = false;
        try {
            Integer dongMai_id = ((DongMaiPo) po).getDongmai_id();
            if (dongMai_id == null) {
                dongMaiPoDao.insert((DongMaiPo) po);
            } else {
                dongMaiPoDao.updateByPrimaryKey((DongMaiPo) po);
            }
            result = true;
        } catch (Exception e) {
            log.error(e.getMessage());
            result = false;
        }
        return result;
    }
}
